package p270jp.pxv.android.viewholder;

import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.lifecycle.AbstractC0721k;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
import p064c6.Preconditions;
import p181ge.AdViewHolder;
import p189gn.AbstractC3435a;
import p216hn.DefaultConstructorMarker;
import p216hn.Reflection;
import p270jp.pxv.android.R;
import p270jp.pxv.android.legacy.model.GoogleNg;
import p284ke.AdUtils;
import p314lg.ViewAdgenerationRectItemBinding;
import p325m0.MutabilityOwnership;
import p350mp.Timber;
import p376no.Koin;
import p404oo.AbstractC5475a;
import p521th.FlexibleItemAdapterSolidItem;
import p521th.SolidItemViewHolder;
import p579vo.Qualifier;
import p603wm.AbstractC6949c;

/* compiled from: RectangleAdsSolidItem.kt */
/* renamed from: jp.pxv.android.viewholder.RectangleAdsSolidItem */
/* loaded from: classes2.dex */
public final class RectangleAdsSolidItem extends FlexibleItemAdapterSolidItem implements AbstractC5475a {
    public static final int $stable;
    private final AbstractC6949c adUtils$delegate = Preconditions.m9802P(1, new AbstractC3435a<AdUtils>(null, null) { // from class: jp.pxv.android.viewholder.RectangleAdsSolidItem$special$$inlined$inject$default$1
        public final /* synthetic */ AbstractC3435a $parameters;
        public final /* synthetic */ Qualifier $qualifier;

        {
            this.$qualifier = r2;
            this.$parameters = r3;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [java.lang.Object, ke.a] */
        @Override // p189gn.AbstractC3435a
        public final AdUtils invoke() {
            Koin koin = AbstractC5475a.this.getKoin();
            return koin.f24118a.m920a().m621a(Reflection.m5499a(AdUtils.class), this.$qualifier, this.$parameters);
        }
    });

    /* compiled from: RectangleAdsSolidItem.kt */
    /* renamed from: jp.pxv.android.viewholder.RectangleAdsSolidItem$RectangleAdsSolidItemViewHolder */
    /* loaded from: classes2.dex */
    public static final class RectangleAdsSolidItemViewHolder extends SolidItemViewHolder implements LifecycleObserver, AdViewHolder {
        private final ViewAdgenerationRectItemBinding binding;
        private GoogleNg googleNg;
        private boolean shouldRunningRotation;
        public static final Companion Companion = new Companion(null);
        public static final int $stable = 8;

        /* compiled from: RectangleAdsSolidItem.kt */
        /* renamed from: jp.pxv.android.viewholder.RectangleAdsSolidItem$RectangleAdsSolidItemViewHolder$Companion */
        /* loaded from: classes2.dex */
        public static final class Companion {
            private Companion() {
            }

            public /* synthetic */ Companion(DefaultConstructorMarker eVar) {
                this();
            }

            public final RectangleAdsSolidItemViewHolder createViewHolder(ViewGroup viewGroup) {
                MutabilityOwnership.m3745m(viewGroup, "parent");
                ViewDataBinding c = DataBindingUtil.m11370c(LayoutInflater.from(viewGroup.getContext()), R.layout.view_adgeneration_rect_item, viewGroup, false);
                MutabilityOwnership.m3746l(c, "inflate(\n               …lse\n                    )");
                return new RectangleAdsSolidItemViewHolder((ViewAdgenerationRectItemBinding) c, null);
            }
        }

        private RectangleAdsSolidItemViewHolder(ViewAdgenerationRectItemBinding z5Var) {
            super(z5Var.f2666e);
            this.binding = z5Var;
            this.googleNg = GoogleNg.WHITE;
        }

        public /* synthetic */ RectangleAdsSolidItemViewHolder(ViewAdgenerationRectItemBinding z5Var, DefaultConstructorMarker eVar) {
            this(z5Var);
        }

        private final void pauseRotation() {
            Timber.f23100a.mo3528a("pause", new Object[0]);
            this.binding.f22543q.m4647c();
        }

        private final void startRotation() {
            Timber.f23100a.mo3528a("start", new Object[0]);
            this.binding.f22543q.setGoogleNg(getGoogleNg());
            this.binding.f22543q.m4645e();
        }

        public GoogleNg getGoogleNg() {
            return this.googleNg;
        }

        @Override // p181ge.AdViewHolder
        public void handleOnAttached() {
            this.shouldRunningRotation = true;
            startRotation();
        }

        @Override // p181ge.AdViewHolder
        public void handleOnDetached() {
            this.shouldRunningRotation = false;
            pauseRotation();
        }

        @OnLifecycleEvent(AbstractC0721k.EnumC0723b.ON_PAUSE)
        public final void handleOnPause() {
            pauseRotation();
        }

        @OnLifecycleEvent(AbstractC0721k.EnumC0723b.ON_RESUME)
        public final void handleOnResume() {
            if (this.shouldRunningRotation) {
                startRotation();
            }
        }

        @Override // p521th.SolidItemViewHolder
        public void onBindViewHolder(int i) {
        }

        @OnLifecycleEvent(AbstractC0721k.EnumC0723b.ON_DESTROY)
        public final void releaseAd() {
            this.binding.f22543q.m4646d();
        }

        @Override // p181ge.AdViewHolder
        public void setGoogleNg(GoogleNg googleNg) {
            MutabilityOwnership.m3745m(googleNg, "<set-?>");
            this.googleNg = googleNg;
        }
    }

    private final AdUtils getAdUtils() {
        return (AdUtils) this.adUtils$delegate.getValue();
    }

    @Override // p404oo.AbstractC5475a
    public Koin getKoin() {
        return AbstractC5475a.C5476a.m3211a(this);
    }

    @Override // p521th.FlexibleItemAdapterSolidItem
    public int getSpanSize() {
        return 2;
    }

    @Override // p521th.FlexibleItemAdapterSolidItem
    public SolidItemViewHolder onCreateViewHolder(ViewGroup viewGroup) {
        MutabilityOwnership.m3745m(viewGroup, "parent");
        return RectangleAdsSolidItemViewHolder.Companion.createViewHolder(viewGroup);
    }

    @Override // p521th.FlexibleItemAdapterSolidItem
    public boolean shouldBeInserted(int i, int i2, int i3, int i4) {
        if (getAdUtils().m4078a() && i / 2 == (i3 + 1) * 15 && i4 % 2 == 0) {
            return true;
        }
        return false;
    }
}
